<?php


namespace apps\marriage\app\op\controller;


use apps\marriage\core\logic\RegionLogic;
use think\Request;

class RegionController extends BaseMarriageOpController
{
    /**
     * @var RegionLogic
     */
    private $regionLogic;

    protected function init()
    {
        parent::init();
        $this->regionLogic = logic('Region', LOGIC_NAMESPACE);
    }

    public function tree()
    {
        return $this->success(['regions' => $this->regionLogic->tree()]);
    }

    public function all()
    {
        return $this->success(['regions' => $this->regionLogic->all()]);
    }

    public function children(Request $request)
    {
        $parentId = $request->param('parent_id', 0, 'intval');
        return $this->success(['regions' => $this->regionLogic->lists($parentId)]);
    }
}